home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Games / General / RoboWar 3.1 / RoboWar 3.1.rsrc / TEXT_2004_Help 4.txt < prev    next >
Text File  |  1994-02-02  |  16KB  |  276 lines

  1. IV:  Operators
  2.  
  3. This section lists each operator.  It gives the name and the effect it has on the stack or robot state.  The operands are as follows:
  4.  
  5. +                      -                      *                       /                     >
  6. <                      =                      !                        STO / STORE
  7. DROP                SWAP               ROLL                 JUMP / RETURN
  8. CALL                DUP / DUPLICATE                      IF                     IFE
  9. (RECALL)          (END)                NOP                  AND                 OR
  10. XOR / EOR         MOD                 BEEP                ARCTAN            COS
  11. ICON0               ICON3               ICON6               ICON9               VSTORE
  12. CHS                  ABS                  TAN                 ICON1               ICON4
  13. ICON7               PRINT               VRECALL           NOT                  SIN
  14. SQRT                ICON2               ICON5               ICON8               SYNC
  15. DIST                 IFG                   IFEG                  DEBUGGER        SND0
  16. SND1                SND2               SND3                 SND4                SND5
  17. SND6                SND7               SND8                 SND9                INTON
  18. INTOFF              RTI                  SETINT              SETPARAM       DROPALL
  19.  
  20. +
  21. Adds the top two numbers on the stack, removes them, and replaces them with the result.
  22. Ex: ‚Äú4 5 +‚Äù leaves 9 on the top of the stack.
  23.  
  24. -
  25. Subtracts the top number from the second number on the stack, removes them, and replaces them with the result.
  26. Ex: ‚Äú9 3 -‚Äù leaves 6 on the top of the stack.
  27.  
  28. *
  29. Multiplies the top two numbers on the stack, removes them, and replaces them with the result.
  30. Ex: ‚Äú2 4 *‚Äù leaves 8 on the top of the stack.
  31.  
  32. /
  33. Divides the second number by the top number on the stack, removes them, and replaces them with the result.
  34. Ex: ‚Äú22 3 /‚Äù leaves 7 on the top of the stack.  (7.3333 is truncated to 7)
  35.  
  36. >
  37. Checks if the second number on the stack exceeds the top number, then removes them.  If the second number is greater, it places a 1 on the stack, otherwise it pushes a 0.
  38. Ex: ‚Äú5 4 >‚Äù leaves a 1 on the stack.
  39.  
  40. <
  41. Checks if the second number on the stack is less than the top number, then removes them.  If the second number is less, it places a 1 on the stack, otherwise it pushes a 0.
  42. Ex: ‚Äú7 3 <‚Äù leaves a 0 on the stack.
  43.  
  44. =
  45. Checks if the top two numbers on the stack are equal, then removes them.  If they are equal, it places a 1 on the stack, otherwise it pushes a 0.
  46. Ex: ‚Äú2 2 =‚Äù leaves a 1 on the stack.
  47.  
  48. !
  49. Checks if the top two numbers on the stack are not equal, then removes them.  If they are not equal, it places a 1 on the stack, otherwise it pushes a 0.  (The symbol ! comes from the logical NOT command in the language C.)
  50. Ex: ‚Äú5 5 !‚Äù leaves a 0 on the stack.
  51.  
  52. STO or STORE (either token is allowed)
  53. Stores the second number on the stack in the variable specified at the top of the stack, and removes both the number and variable reference.  The operand on the top of the stack must be a quoted variable or an error is reported.  Also see the section on variables below, as values cannot be stored in some variables, such as RANGE.
  54. EX: ‚Äú20 aim‚Äô store‚Äù stores 20 in the variable AIM and leaves nothing on the stack.
  55.  
  56. DROP
  57. Drops the top element from the stack.
  58. EX: ‚Äú5 DROP‚Äù leaves nothing on the stack.
  59.  
  60. SWAP
  61. Swaps the top and second elements on the stack.
  62. EX: ‚Äú1 2 SWAP‚Äù leaves 1 at the top of the stack and 2 in the second position.
  63.  
  64. ROLL
  65. Rolls the second element of the stack back the number of places specified by the top operand, then removes the top operand.
  66. EX: ‚Äú1 2 3 4 5 2 ROLL‚Äù rolls 5 back 2 places, leaving 1 2 5 3 4 on the stack.
  67.  
  68. JUMP or RETURN (either token is allowed)
  69. Jumps to the instruction number specified by the top element of the stack, removes the top element, and resumes execution at the new instruction.  The same operator, usually written with the name RETURN, returns after a subroutine call made by IF or CALL by jumping to the return address that the IF or CALL left on the top of the stack.
  70.  
  71. CALL
  72. Jumps to the instruction number specified by the top element of the stack, removes the top element, places the return address (the instruction number previously being executed) on the top of the stack, and resumes execution at the new instruction.  Very similar to JUMP, but leaves the return address on the stack.
  73.  
  74. DUP or DUPLICATE (either token is allowed)
  75. Duplicates the number on the top of the stack.
  76. EX: ‚Äú5 DUP‚Äù leaves 5 on the top of the stack and 5 in the second position.
  77.  
  78. IF
  79. Checks the second operand on the stack.  If it is not zero then it leaves the return address on the stack and jumps to the label specified on the top of the stack.  In any case, it removes the second operand and the destination label from the stack.
  80. EX: ‚Äú1 MySub IF‚Äù jumps to the subroutine MySub and leaves the return address on the stack.
  81.  
  82. IFE
  83. Stands for IF-THEN-ELSE.  Checks the third operand on the stack.  If it is not zero than it leaves the return address on the stack and jumps to the label specified in the second position on the stack.  If it is zero then it leaves the return address on the stack and jumps to the label specified on the top of the stack.  In any case it removes the first, second, and third elements from the stack.
  84. EX: ‚Äú0 SubA SubB IFE‚Äù jumps to the subroutine SubB and leaves the return address on the stack.
  85.  
  86. NOP
  87. No OPeration.  Does nothing whatsoever, except take up time and space.  May be used when some timing loop is necessary.
  88. EX: ‚ÄúNOP‚Äù leaves nothing on the stack.
  89.  
  90. AND
  91. Checks if the top two numbers on the stack are both not zero, then removes them.  If they are both not zero, it places a 1 on the stack, otherwise it pushes a 0.
  92. EX: ‚Äú2 3 AND‚Äù leaves a 1 on the top of the stack.
  93.  
  94. OR
  95. Checks if either of the top two numbers on the stack is not zero, then removes them.  If either is not zero, it places a 1 on the stack, otherwise it pushes a 0.
  96. EX: ‚Äú0 4 OR‚Äù leaves a 1 on the top of the stack.
  97.  
  98. XOR or EOR (either token is allowed)
  99. Checks the top two numbers on the stack, then removes them.  If one or the other, but not both, are not zero, it places a 1 on the stack.  Otherwise, it pushes a 0.
  100. EX: ‚Äú1 2 XOR‚Äù leaves a 0 on the top of the stack.
  101.  
  102. MOD
  103. Performs a modulus operation (remainder of integer division) on the top two elements of the stack.  Removes them and returns the result on the stack.
  104. EX: ‚Äú10 3 MOD‚Äù leaves 10 mod 3 = 10-3*Trunc(10/3) = 1 on the stack.
  105.  
  106. BEEP
  107. Beeps once.  Most useful in debugging a robot.
  108. EX: ‚ÄúBEEP‚Äù leaves nothing on the stack.
  109.  
  110. CHS
  111. CHange Sign.  Multiplies the top operand on the stack by -1, removes it, and returns the result on the stack.
  112. EX: ‚Äú3 CHS‚Äù leaves -3 on the stack.
  113.  
  114. NOT
  115. Logical Not.  Checks top operand, removes it.  Returns 1 if it was 0, 0 otherwise.
  116. EX: ‚Äú4 NOT‚Äù leaves 0 on the stack.
  117.  
  118. ARCTAN
  119. Inverse Tangent.  Computes the inverse tangent of the ratio of the top two numbers.  The y value must be the top operand; the x value must be the second operand.  ARCTAN removes the top two operands and returns the arctangent of y/x.  The result is in degrees between 0 and 359, with 0 degrees pointing up, just as with AIM angles.
  120. EX:  ‚Äú-5 0 ARCTAN‚Äù leaves 270 on the stack.
  121.  
  122. ABS
  123. Absolute Value.  Removes the top argument and returns its absolute value.
  124. EX:  ‚Äú-8 ABS‚Äù leaves 8 on the stack.
  125.  
  126. SIN or SINE
  127. Sine function.  The top argument should be the hypotenuse and the second argument should be the angle.  Sine removes the top two arguments and returns the hypotenuse times the sine of the angle, truncated to an integer value.  The angle must be between 0 and 359 or the result is undefined.  Also, note that while 0 degrees is pointing straight up on the turret, the sine of 0 degrees is still 0.
  128. EX: ‚Äú30 100 SIN‚Äù leaves 50 (=100*sin(30) on the stack.
  129.  
  130. COS or COSINE
  131. Identical to SIN above, but computes the cosine function.
  132.  
  133. TAN or TANGENT
  134. Identical to SIN above, but computes the tangent function.  If the result is greater than 19999 it is clipped to 19999; if the result is less than -19999, it is clipped to -19999.
  135.  
  136. SQRT
  137. Square root function.  Removes the top argument and returns its square root, truncated to an integer.  If the argument is less than zero, an error results and the robot self-destructs.
  138. EX: ‚Äú10 SQRT‚Äù leaves 3 on the stack.
  139.  
  140. ICON0
  141. Sets the robot‚Äôs icon to standard state (display icon #0 if shields are off, display icon #1 if shields are up).  Takes zero chronons to execute.  The various icon commands are used for icon animation.
  142. EX:  ‚ÄúICON0‚Äù does nothing to the stack.
  143.  
  144. ICON1
  145. Sets the robot‚Äôs icon to icon 1 until the next call if one of the icon commands.  Takes zero chronons to execute.
  146. EX:  ‚ÄúICON1‚Äù does nothing to the stack.
  147.  
  148. ICON2
  149. Sets the robot‚Äôs icon to icon 2 until the next call if one of the icon commands.  Takes zero chronons to execute.
  150. EX:  ‚ÄúICON2‚Äù does nothing to the stack.
  151.  
  152. ICON3
  153. Sets the robot‚Äôs icon to icon 3 until the next call if one of the icon commands.  Takes zero chronons to execute.
  154. EX:  ‚ÄúICON3‚Äù does nothing to the stack.
  155.  
  156. ICON4
  157. Sets the robot‚Äôs icon to icon 4 until the next call if one of the icon commands.  Takes zero chronons to execute.
  158. EX:  ‚ÄúICON4‚Äù does nothing to the stack.
  159.  
  160. ICON5
  161. Sets the robot‚Äôs icon to icon 5 until the next call if one of the icon commands.  Takes zero chronons to execute.
  162. EX:  ‚ÄúICON5‚Äù does nothing to the stack.
  163.  
  164. ICON6
  165. Sets the robot‚Äôs icon to icon 6 until the next call if one of the icon commands.  Takes zero chronons to execute.
  166. EX:  ‚ÄúICON6‚Äù does nothing to the stack.
  167.  
  168. ICON7
  169. Sets the robot‚Äôs icon to icon 7 until the next call if one of the icon commands.  Takes zero chronons to execute.
  170. EX:  ‚ÄúICON7‚Äù does nothing to the stack.
  171.  
  172. ICON8
  173. Sets the robot‚Äôs icon to icon 8 until the next call if one of the icon commands.  Takes zero chronons to execute.
  174. EX:  ‚ÄúICON8‚Äù does nothing to the stack.
  175.  
  176. ICON9
  177. Sets the robot‚Äôs icon to icon 9 until the next call if one of the icon commands.  Takes zero chronons to execute.
  178. EX:  ‚ÄúICON9‚Äù does nothing to the stack.
  179.  
  180. PRINT
  181. Displays the top element of the stack in a dialog box.  Takes zero chronons to execute.  Intended for debugging purposes only; implemented since the debugger is not yet written.
  182. EX:  ‚Äú5 PRINT‚Äù leaves 5 on the stack and displays a dialog box reading ‚Äú5‚Äù
  183.  
  184. SYNC
  185. Ceases execution of code until the end of chronon.  The next instruction will be executed at the next chronon.
  186.  
  187. VSTORE
  188. Store a element in a vector (1 dimensional array).  The top element specifies the element of the vector (1 to 100) while the second element is the number to store.  Both arguments are removed from the stack.
  189. EX:  ‚Äú42 1 VSTORE‚Äù stores 42 in the first element of the vector.
  190.  
  191. VRECALL
  192. Returns the nth element of the vector.  The top of the stack holds the element to reference; it is removed and replaced by the contents of the vector.  Uninitialized vector elements default to zero.  If the element number is less than 1 or greater than 100, zero is also returned.
  193. EX:  ‚Äú1 VRECALL‚Äù leaves 42 on the stack assuming the previous example was last executed.
  194.  
  195. DIST
  196. Calculate the distance from the origin to some point (x,y) = Sqrt(x*x+y*y).  The top two elements of the stack are x and y; they are removed and replaced with the distance.
  197. EX:  ‚Äú10 10 DIST‚Äù leaves 14 on the stack.
  198.  
  199. IFG
  200. Stands for IF-GOTO.  Checks the second operand on the stack.  If it is not zero then it jumps to the label specified on the top of the stack without leaving a return address.  In any case, it removes the second operand and the destination label from the stack.
  201. EX: ‚ÄúRANGE TARGETING IFG‚Äù jumps to the label TARGETING if a hostile robot is in the line of fire and leaves nothing on the stack.
  202.  
  203. IFEG
  204. Stands for IF-THEN-ELSE-GOTO.  Checks the third operand on the stack.  If it is not zero than it jumps to the label specified in the second position on the stack.  If it is zero then it jumps to the label specified on the top of the stack.  Unlike IFE, it leaves no return address.  In any case it removes the first, second, and third elements from the stack.
  205. EX: ‚Äú0 SubA SubB IFEG‚Äù jumps to the subroutine SubB, leaving nothing on the stack
  206.  
  207. DEBUG/DEBUGGER
  208. A hook for debugging.  If the robot is selected for debugging (i.e. has the bug icon beside it in the Arena display), tthis command acts as a sync instruction, pausing until the end of the chronon (because the debugger cannot turn on in the middle of a chronon).   Execution pauses immediately after the debugger instruction and one can use the debugger facilities.  If the robot is not selected for debugging, nothing happens and no time is used (so that one can run accurate timing on a robot without having to remove DEBUG statements).
  209. EX:  "DEBUGGER" pauses until the end of chronon and enters the debugger if debugger is on
  210.  
  211. SND0
  212. Plays Sound #0 defined in the Recording Studio.  Sound #0 is also automatically played upon death of a robot.  Takes zero chronons to execute.  The various other SND commands are used to enliven a robot with sound effects and to waste ungodly amounts of disk space.
  213.  
  214. EX:  ‚ÄúSND0‚Äù does nothing to the stack.
  215.  
  216. SND1
  217. Plays Sound #1.  Sound #1 is also automatically played during collisions involving the robot.  Takes zero chronons to execute.
  218. EX:  ‚ÄúSND1‚Äù does nothing to the stack.
  219.  
  220. SND2
  221. Plays Sound #2.  Sound #2 is also automatically played when the robot is hit but all damage is absorbed by its shields.  Takes zero chronons to execute.
  222. EX:  ‚ÄúSND2‚Äù does nothing to the stack.
  223.  
  224. SND3
  225. Plays Sound #3.  Sound #3 is also automatically played when the robot is hit and damage penetrates the shields.  Takes zero chronons to execute.
  226. EX:  ‚ÄúSND3‚Äù does nothing to the stack.
  227.  
  228. SND4
  229. Plays Sound #4.  Takes zero chronons to execute.
  230. EX:  ‚ÄúSND4‚Äù does nothing to the stack.
  231.  
  232. SND5
  233. Plays Sound #5.  Takes zero chronons to execute.
  234. EX:  ‚ÄúSND5‚Äù does nothing to the stack.
  235.  
  236. SND6
  237. Plays Sound #6.  Takes zero chronons to execute.
  238. EX:  ‚ÄúSND6‚Äù does nothing to the stack.
  239.  
  240. SND7
  241. Plays Sound #7.  Takes zero chronons to execute.
  242. EX:  ‚ÄúSND7‚Äù does nothing to the stack.
  243.  
  244. SND8
  245. Plays Sound #8.  Takes zero chronons to execute.
  246. EX:  ‚ÄúSND8‚Äù does nothing to the stack.
  247.  
  248. SND9
  249. Plays Sound #9.  Takes zero chronons to execute.
  250. EX:  ‚ÄúSND9‚Äù does nothing to the stack.
  251.  
  252. INTON
  253. Turns interrupts on.  Must be used near start of any robot that uses interrupts.
  254. EX:  ‚ÄúINTON‚Äù does nothing to the stack.
  255.  
  256. INTOFF
  257. Turns interrupts off until next INTON command.
  258. EX:  ‚ÄúINTOFF‚Äù does nothing to the stack.
  259.  
  260. RTI
  261. Returns from interrupt.  First enables interrupts like INTON, then pops return address from top of stack and jumps there like RETURN.
  262. EX: ‚ÄúRTI‚Äù removes return address from stack.
  263.  
  264. SETINT
  265. Sets an interrupt procedure to execute when interrupt occurs and interrupts are enabled.  The top of the stack must have the name of the register corresponding to the interrupt (choices are COLLISION, WALL, DAMAGE, TOP, BOTTOM, LEFT, RIGHT, RADAR, RANGE, and SIGNAL).  The second item on the stack must be the address of a routine that handles the interrupt.
  266. EX:  ‚Äúpanicsub RADAR' SETINT‚Äù leaves nothing on the stack.
  267.  
  268. SETPARAM
  269. Sets a parameter controlling when interrupts occur.  The top of the stack must have the name of the register corresponding to the interrupt.  The second item on the stack is the value to which the parameter will be set.  Note that COLLISION and WALL ignore their parameters.  The remaining default parameters are 150 for DAMAGE, 20 for TOP, 280 for BOTTOM, 20 for LEFT, 280 for RIGHT, 600 for RADAR and RANGE, and 0 for SIGNAL.
  270. EX:  ‚Äú100 RANGE' SETPARAM‚Äù leaves nothing on the stack.
  271.  
  272. DROPALL
  273. This command drops everything off of the stack.  It is useful for interrupt routines that may not return to where they were called, thus leaving an unknown amount of junk on the stack.  It is also useful for sloppy programmers who let junk accumulate on the stack and run into stack overflows after lots of chronons.
  274. EX:  ‚Äú87 42 99 -32 DROPALL‚Äù leaves absolutely nothing on the stack.
  275.  
  276.